#include "DelayTest.h"

DelayTest::DelayTest( void )
{

}

DelayTest::~DelayTest( void )
{

}

DelayTest* DelayTest::startDelayTest(std::string tag, long showCondition)
{
	DelayTest* dl = new DelayTest();
	timeval t;
	gettimeofday(&t, NULL);
	dl->time = t;
	dl->tag = tag;
	dl->showCondition = showCondition;
	return dl;
}

void DelayTest::endDelayTest(DelayTest* dl)
{
	timeval t;
	gettimeofday(&t, NULL);
	long delta = (t.tv_usec - dl->time.tv_usec) + (t.tv_sec - dl->time.tv_sec)*1000000;
	if(delta > dl->showCondition)
	{
		CCLog("DelayTest %s: %d", dl->tag.c_str(), delta);
	}

	delete dl;
}
